package com.read.service.impl;

import com.read.dto.params.NovelClickParamsDto;
import com.read.dto.params.NovelUserRecommendParamsDto;
import com.read.mapper.NovelClickMapper;
import com.read.mapper.NovelUserRecommendMapper;
import com.read.service.ClickService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author sh-sunb6
 * @description
 * @date 2019-03-09 13:17
 */
@Service
public class ClickServiceImpl implements ClickService {

    private static final Logger logger = LoggerFactory.getLogger(ClickServiceImpl.class);

    @Autowired
    private NovelUserRecommendMapper novelUserRecommendMapper;

    @Autowired
    private NovelClickMapper novelClickMapper;

    @Override
    public int addNovelUserRecommend(NovelUserRecommendParamsDto paramsDto) {
        return novelUserRecommendMapper.insertNovelUserRecommend(paramsDto);
    }

    @Override
    public int cancelNovelUserRecommend(int novelId, int userId) {
        return novelUserRecommendMapper.updateNovelUserRecommendState(novelId, userId);
    }

    @Override
    public boolean isUserRecommendNovel(int novelId, int userId) {
        int i = novelUserRecommendMapper.selectNovelUserRecommendCountByNovelIdUserId(novelId, userId);
        return (i == 0) ? false : true;
    }

    @Override
    public void addNovelSystemRecommend(NovelClickParamsDto paramsDto) {
        novelClickMapper.insertNovelClick(paramsDto);
    }
}
